<?
$sub_menu = "700100";
include_once("./_common.php");

auth_check($auth[$sub_menu], "r");

$token = get_token();

$g4[title] = "방문일지 관리";
include_once("./admin.head.php");

if($w == "u") {
	$sql = "SELECT	*
			FROM	visit_record
			WHERE	id = '$id'";
	$rst = sql_query($sql);
	$write = mysql_fetch_assoc($rst);
} else {
	$w = "";
}

$sql = "select wr_1 from g4_write_branch order by wr_1 ASC";
$rst = sql_query($sql);
while($row = mysql_fetch_assoc($rst)) {
	$store[] = $row;
}



?>
<style>
div.title_wrap1 {margin-top:30px;}
div.title_wrap1 h3 {width:160px;text-align:center;margin:0 auto; font-family:"나눔고딕";color:#fff; padding:7px 0px; background-color:#5970a4;}
div.table1 {}
div.table1 p {text-align:left;margin:5px 0;}
table.info1 {border:2px solid #5970a4;width:98%;}
table.info1 tr {height:40px;border-top:1px solid #d9d9d9;}
table.info1 th {border-top:1px solid #fff;xborder-right:1px solid #fff;background-color:#5970a4; xfont-weight:normal; text-align:left; padding-left:5px;height:39px; color:#fff;}
table.info1 td {border-top:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;text-align:left;padding-left:10px;}
div.table2 {}
table.info2 {border:2px solid #5970a4;width:98%; margin-top:20px;}
table.info2 tr {height:40px;border-top:1px solid #d9d9d9;}
table.info2 th {border-top:1px solid #fff;xborder-right:1px solid #fff;background-color:#5970a4; xfont-weight:normal; text-align:left; padding-left:5px;height:39px; color:#fff;}
table.info2 td {border-top:1px solid #ccc;border-right:1px solid #ccc;border-left:1px solid #ccc;text-align:left;padding-left:10px;}
.txtwd {width:99%;}
.tareawd {width:99%}
div.table2 p {text-align:right}
</style>
<div class="wrap">
	<div class="title_wrap1">
		<h1>방 문 일 지</h1>
	</div>
	<form action="./m_visit_update.php?bo_table=visit" method="post">
		<input type="hidden" name="id" value="<?php echo $id?>" />
		<input type="hidden" name="w" value="<?php echo $w?>" />
		<div class="table1">
			<p>No. : <input type="text" name="vi_no" value="<?php echo $write['vi_no']?>" /></p>
			<table class="info1" border=0 cellspacing=0 cellpadding=0>
			<colgroup>
			<col width="180px" />
			<col width="" />
			</colgroup>
			<tr>
			<th><span class="xthtxt">*</span> 방문일자</th>
			<td>
				<?php
				if($w == "") {
					$today = date("Y-m-d");
					$year = substr($today,2,2);
					$month = substr($today,5,2);
					$date = substr($today,8,2);
					$today_str = "20".$year."년 ".$month."월 ".$date."일";

					$time = date("a:h:i:s");
					if(substr($time,0,3) == "am:") {
						$ampm = "오전 ";
					} else if (substr($time,0,3) == "pm:") {
						$ampm = "오후 ";
					}
					$time_str = $ampm.date("h : i : s");

					echo "<span class='xtdtxt'>".$today_str."</span>";
				?>
					<input type="hidden" name="vi_date" value="<?php echo $today_str?>" />
				<? } else if ($w == "u") {
					echo "<span class='xtdtxt'>".$write['vi_date']."</span>";
				?>
					<input type="hidden" name="vi_date" value="<?php echo $write['vi_date']?>" />
				<? } ?>
			</td>
			</tr>
			<tr>
			<th>구분</th>
			<td>
				<input type="radio" name="vi_flag" class="vi_flag" value="감리" <?php echo $w == "" ? "checked" : ""?> />감리
				<input type="radio" name="vi_flag" class="vi_flag" value="정기점검" />정기점검
				<input type="radio" name="vi_flag" class="vi_flag" value="분쟁" />분쟁
				<input type="radio" name="vi_flag" class="vi_flag" value="위반사항" />위반사항
			</td>
			</tr>
			<script>
			$(".vi_flag").val(["<?php echo $write['vi_flag']?>"]);
			</script>
			<tr>
			<th><span class="xthtxt">*</span> 방문자</th>
			<td>
				<?php
				if($w == "") {
					echo "<span class='xtdtxt'>".$member['mb_name']."</span>";
				?>
					<input type="hidden" name="vi_name1" value="<?php echo $member['mb_name']?>" />
				<? } else if ($w == "u") {
					echo "<span class='xtdtxt'>".$write['vi_name1']."</span>";
				?>
					<input type="hidden" name="vi_name1" value="<?php echo $write['vi_name1']?>" />
				<? } ?>
			</td>
			</tr>
			<tr>
			<th><span class="xthtxt">*</span> 방문시간</th>
			<td>
				<?php
				if($w == "") {
					echo "<span class='xtdtxt'>".$time_str."</span>";
				?>
					<input type="hidden" name="vi_time" value="<?php echo $time_str?>" />
				<? } else if ($w == "u") {
					echo "<span class='xtdtxt'>".$write['vi_time']."</span>";
				?>
					<input type="hidden" name="vi_time" value="<?php echo $write['vi_time']?>" />
				<? } ?>
			</td>
			</tr>
			</table>
		</div>
		<div class="table2">
			<table class="info2" border=0 cellspacing=0 cellpadding=0>
			<colgroup>
			<col width="180px" />
			<col width="" />
			</colgroup>
			<tr>
			<th><span class="xthtxt">*</span> 점명</th>
			<td>
				<!--?php echo "<span class='xtdtxt'>".$write['vi_store']."</span>"?>-->
					<!-- input type="text" name="vi_store" value="<?php echo $write['vi_store']?>" /-->
					<select name="select_store" class="select_store">
					<option value="all">전체지점</option>
					<?php
					for($i = 0; $i < count($store); $i += 1) { 
						if( $store[$i]['wr_1'] == $write['vi_store']){
							$sel = 'selected="selected"';
						}else{ 
							$sel = '';
						}
					?>
					<option value="<?php echo $store[$i]['wr_1']?>" <?=$sel ?>><?php echo $store[$i]['wr_1']?></option>
					<?}?>
					</select>
					
				
			</td>
			</tr>
			<tr>
			<th>점주명</th>
			<td><input type="text" class="txtwd" name="vi_name2" value="<?php echo $write['vi_name2']?>" /></td>
			</tr>
			<tr>
			<th>직원수</th>
			<td><input type="text" class="txtwd" name="vi_count" value="<?php echo $write['vi_count']?>" /></td>
			</tr>
			<tr>
			<th>평균고객수</th>
			<td><input type="text" class="txtwd" name="vi_avg" value="<?php echo $write['vi_avg']?>" /></td>
			</tr>
			<tr>
			<th>홀 유지 관리상태</th>
			<td >
			<?php if ($write['vi_hall'] == 1){
				$ck_allow = 'checked="checked"';
			 }else if ($write['vi_hall'] == 2){
			 	$ck_deny = 'checked="checked"';
			 }else{
				$ck_allow = "";
				$ck_deny = "";
			 }?>
			<input type="checkbox" value="1" name="hall_allow" <? echo $ck_allow ?>>양호</input>
			<input type="checkbox" value="2" name="hall_deny"  <? echo $ck_deny ?>>불량</input>
			<!-- <input type="text" class="txtwd" name="vi_hall" value="<?php echo $write['vi_hall']?>" />-->
			</td>
			</tr>
			<tr>
			<th>간판 유지 관리상태</th>
			<td>
			<?php if ($write['vi_sign'] == 1){
				$ck_allow = 'checked="checked"';
			 }else if ($write['vi_sign'] == 2){
			 	$ck_deny = 'checked="checked"';
			 }else{
				$ck_allow = "";
				$ck_deny = "";
			 }?>
			<input type="checkbox" value="1" name="sign_allow" <? echo $ck_allow ?>>양호</input>
			<input type="checkbox" value="2" name="sign_deny"  <? echo $ck_deny ?>>불량</input>
			<!-- input type="text" class="txtwd" name="vi_sign" value="<?php echo $write['vi_sign']?>" /--></td>
			</tr>
			<tr>
			<th>쇼 윈도우 및 사인물<br />유지 관리상태</th>
			<td>
			<?php if ($write['vi_show'] == 1){
				$ck_allow = 'checked="checked"';
			 }else if ($write['vi_show'] == 2){
			 	$ck_deny = 'checked="checked"';
			 }else{
				$ck_allow = "";
				$ck_deny = "";
			 }?>
			<input type="checkbox" value="1" name="show_allow" <? echo $ck_allow ?>>양호</input>
			<input type="checkbox" value="2" name="show_deny"  <? echo $ck_deny ?>>불량</input>
			<!-- input type="text" class="txtwd" name="vi_show" value="<?php echo $write['vi_show']?>" /--></td>
			</tr>
			<tr>
			<th>카운터 및 주방<br />유지 관리상태</th>
			<td>
			<?php if ($write['vi_cash'] == 1){
				$ck_allow = 'checked="checked"';
			 }else if ($write['vi_cash'] == 2){
			 	$ck_deny = 'checked="checked"';
			 }else{
				$ck_allow = "";
				$ck_deny = "";
			 }?>
			<input type="checkbox" value="1" name="cash_allow" <? echo $ck_allow ?>>양호</input>
			<input type="checkbox" value="2" name="cash_deny"  <? echo $ck_deny ?>>불량</input>
			<!-- input type="text" class="txtwd" name="vi_cash" value="<?php echo $write['vi_cash']?>" /--></td>
			</tr>
			<tr>
			<th>유니폼 착용 유무</th>
			<td>
			<?php if ($write['vi_uni'] == 1){
				$ck_allow = 'checked="checked"';
			 }else if ($write['vi_uni'] == 2){
			 	$ck_deny = 'checked="checked"';
			 }else{
				$ck_allow = "";
				$ck_deny = "";
			 }?>
			<input type="checkbox" value="1" name="uni_allow" <? echo $ck_allow ?>>유</input>
			<input type="checkbox" value="2" name="uni_deny"  <? echo $ck_deny ?>>무</input>
			<!-- input type="text" class="txtwd" name="vi_uni" value="<?php echo $write['vi_uni']?>" /--></td>
			</tr>
			<tr>
			<th colspan="2">내용</th>
			</tr>
			<tr>
			<td colspan="2"><textarea name="vi_content" rows="30" class="tareawd"><?php echo $write['vi_content']?></textarea></td>
			</tr>
			</table>
			<br />
			<p>점주 확인 : <input type="text" name="vi_confirm" value="<?php echo $write['vi_confirm']?>" />
			<!-- <input type="button" name="vi_sign" class="bt_sign" value="(서명)" />-->
			<td style="width:70px;">
				<input type="hidden" name="in_sign_img2" id="in_sign_img2" required value="<?php echo $in_sign_img2?>" />
				<span name="in_sign_img2" class="isi2 cp" style="text-align:left">(인) 또는 서명</span>
			</td>
			</p>
		</div>
		<input type="submit" value="저장" class="btn1" />
		<input type="button" value="목록" class="vi_list btn1" />
	</form>
	<br />
</div>
<br />

<script>
$(".isi2").click(function() {
	window.open("http://augustin.co.kr/adm/adm_new/confirm_code2.php#simple","confirm","menubar=no,toolbar=no,location=no,scrollbars=no,status=no,fullscreen=no");

});
$(".vi_list").click(function() {
	location.href = "./m_visit_list.php?bo_table=visit";
});
</script>
<?
include_once("../admin.tail.php");
?>
